﻿using System;
using Myotragus.Data;
using Myotragus.Data.Containers;
using Myotragus.Data.Domain;
using Myotragus.Data.RepositoryExtensions;
using Myotragus.Store.Model.Tests.Domain;
using Myotragus.Store.Model.Tests.Mocks;
using NUnit.Framework;

namespace Myotragus.Store.Model.Tests
{
  [TestFixture(typeof(IObject))]
  class RepositoryCruds<TEntity>
    where TEntity : IEntity
  {
    [SetUp]
    public void SetUp()
    {
      Entities = MockServices.Entities<TEntity>();
      Services = MockServices.Services();
    }

    [Test]
    public void CrudOperations()
    {
      var repo = new ReadWriteRepo<TEntity>(Entities) {Services = Services};
      var obj = repo.New();
      repo.Save(obj);
    }

    protected readonly Type TypeOfTEntity = typeof(TEntity);
    protected IEntitiesContainer Entities { get; set; }
    protected IServicesContainer Services { get; set; }
    protected ISessionFactoryAdapter FactoryAdapter { get; set; }
  }
}
